package edu.sctu.zhuyingzhi.month201506.day20150618.awtTest;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by user13 on 2015/6/18.
 */
public class InputOutput1 extends JFrame{
    public static final int BOARD_WIDTH = 540;
    public static final int BOARD_HEIGHT = 570;
    public static final int X_LOCATION = 100;
    public static final int Y_LOCATION = 50;

    JPanel northPanel = new JPanel();
    JPanel centerPanel = new JPanel();
    JPanel southPanel = new JPanel();
//输入
    JTextField textField = new JTextField(30);
    JLabel url = new JLabel("start URL:",JLabel.RIGHT);
//输出
    JTextArea textArea = new JTextArea(10,40);
    JLabel txt = new JLabel("resylt");
    //按钮
    JButton startbutton = new JButton("start");
    JButton cancelbutton = new JButton("cancer");

    public void setButton(){
        this.setLocation(X_LOCATION,Y_LOCATION);
        this.setSize(BOARD_WIDTH,BOARD_HEIGHT);
        this.setResizable(false);
        this.setVisible(true);
        this.setLayout(new GridLayout(3,1));
        this.add(northPanel);
        this.add(centerPanel);
        this.add(southPanel);

        northPanel.add(url);
        northPanel.add(textField);

        centerPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
        centerPanel.add(txt);
        centerPanel.add(textArea);

        northPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
        centerPanel.add(startbutton);
        centerPanel.add(cancelbutton);

        startbutton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                System.out.println("获取数据"+textField.getText());
            }
        });

        cancelbutton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("这是取消");
            }
        });


    }

}
